//
//  YYCircleView.swift
//  C014_UIBezierPath
//
//  Created by yao_yu on 15/6/16.
//  Copyright © 2015年 yao_yu. All rights reserved.
//

import UIKit

class YYCircleView: UIView {

    //*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
        // Drawing code
        
        let lwidth:CGFloat = 2
        var aPath: UIBezierPath
        aPath = UIBezierPath(ovalInRect: CGRectMake(lwidth, lwidth, self.frame.size.width - 2 * lwidth, self.frame.size.height - 2 * lwidth))
        aPath = UIBezierPath(ovalInRect: CGRectMake((self.frame.size.width - 100)/2, 20, 100, 50))
        UIColor.blackColor().setStroke()
        UIColor.redColor().setFill()
        aPath.lineWidth = lwidth
        aPath.fill()
        aPath.stroke()
//        var aRef = UIGraphicsGetCurrentContext()
        
        
        aPath = UIBezierPath()
        aPath.lineWidth = 4
        aPath.moveToPoint(CGPointMake(100, 0))
        aPath.addLineToPoint(CGPointMake(200, 40))
        aPath.addLineToPoint(CGPointMake(160, 140))
        aPath.addLineToPoint(CGPointMake(40, 140))
        aPath.addLineToPoint(CGPointMake(0, 40))
        aPath.lineJoinStyle = kCGLineJoinRound
        aPath.closePath()
        aPath.stroke()
        
        createArcPath().stroke()
    }
    
    func createArcPath() -> UIBezierPath {
        let aPath:UIBezierPath = UIBezierPath(arcCenter: CGPointMake(100, 70), radius: 40, startAngle: 0, endAngle: 3, clockwise: true)
//        UIColor.blackColor().setStroke()
        return aPath
    }
    //*/

}
